package com.neudu.glsb.mapper;

import com.neudu.glsb.pojo.AdminUsers;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
* @author Lenovo
* @description 针对表【admin_users(管理员用户信息)】的数据库操作Mapper
* @createDate 2025-04-16 22:28:32
* @Entity com.neudu.glsb.pojo.AdminUsers
*/
@Mapper
public interface AdminUsersMapper extends BaseMapper<AdminUsers> {
    // 获取所有账号信息
    @Select("SELECT au.id, au.username, au.email, au.password, r.role_name, e.employee_name " +
            "FROM admin_users au " +
            "LEFT JOIN roles r ON au.role_id = r.id " +
            "LEFT JOIN employees e ON au.id = e.admin_user_id")
    List<Map<String, Object>> getAllAccounts();
    @Insert("INSERT INTO admin_users (username, password, email, login_method, role_id) VALUES (#{username}, #{password}, #{email}, #{loginMethod}, #{roleId})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insertAdminUser(AdminUsers adminUser);
    @Select("SELECT id, username, password, email, login_method, role_id FROM admin_users WHERE id=#{id}")
    AdminUsers selectById(Integer id);
}






